<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <title><!--{$lang.page.index.title}--></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/lay/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/lay/layui/index.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body" style="padding: 15px;">
        <div class="layui-form-item" style="text-align: center;"><b><!--{$lang.page.mue.accmg}--></b></div>
        <form name="addItem" method="post" lay-filter="component-form-group" class="layui-form">
          <input type="hidden" value="<!--{$datainfo.aid}-->" name="aid">
          <input type="hidden" name="pid" value="<!--{$datainfo.pid}-->">
          <input type="hidden" name="ranges" value="<!--{$datainfo.ranges}-->">
          <input type="hidden" name="grade" value="<!--{$datainfo.grade}-->">
          <input type="hidden" name="roletype" value="<!--{$datainfo.roletype}-->">
          <input type="hidden" name="type" value="1">
          <div class="layui-form-item">

            <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.account}--></label>
              <div class="layui-input-inline">
               <input type="text" name="username" value="<!--{$datainfo.username}-->" lay-verify="username" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
            </div>

            <div class="layui-inline">
             <label class="layui-form-label"><!--{$lang.page.public.password}--></label>
              <div class="layui-input-inline">
                <input type="password" name="password" value="<!--{$datainfo.password}-->" lay-verify="password" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
            </div>

            <div class="layui-inline">
             <label class="layui-form-label"><!--{$lang.page.public.paypwd}--></label>
              <div class="layui-input-inline">
                <input type="password" name="paypwd" value="<!--{$datainfo.paypwd}-->" lay-verify="paypwd" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
            </div>

            <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.realname}--></label>
              <div class="layui-input-inline">
               <input type="text" name="realname" value="<!--{$datainfo.realname}-->" lay-verify="realname" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
            </div>

            <div class="layui-inline">
             <label class="layui-form-label"><!--{$lang.page.table.phone}--></label>
              <div class="layui-input-inline">
                <input type="text" name="mobile" value="<!--{$datainfo.mobile}-->" lay-verify="mobile" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
            </div>

            <div class="layui-inline">
             <label class="layui-form-label"><!--{$lang.page.public.email}--></label>
              <div class="layui-input-inline">
                <input type="text" name="email" value="<!--{$datainfo.email}-->"  placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
              </div>
            </div>

            </div>

            <!--{if $user.grade eq 'superadmin'}-->
            <div class="layui-form-item">
              <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.type}--></label>
              <div class="layui-input-inline" >
                  <select name="roletype" lay-verify="roletype" lay-filter="brickType">
                     <option value=""><!--{$lang.page.public.select}--></option>
                   <!--{foreach item=item from=$rolelist}-->
                     <option range="<!--{$item.ranges}-->" grade="<!--{$item.grade}-->" value="<!--{$item.id}-->" <!--{if $item.id eq $datainfo.roletype}-->selected<!--{/if}-->><!--{$item.title}--></option>
                   <!--{/foreach}-->
                  </select>
              </div>
              <!--{if $user.grade eq 'superadmin' || $datainfo.grade eq 'agent'}-->
              <div class="layui-inline" <!--{if empty($datainfo.usercode)}-->style='display:none'<!--{/if}-->>
                <label class="layui-form-label"><!--{$lang.page.table.promotion}--></label>
                <div class="layui-input-inline">
                  <input type="text" name="usercode" value="<!--{$datainfo.usercode}-->"  placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" readonly />
                </div>
              </div>
            </div>
            <!--{/if}-->
            <!--{if $user.grade eq 'superadmin'}-->
            <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.agent}--></label>
              <div class="layui-input-inline" >
                  <input type="text"  id="subrealname" value="<!--{$datainfo.subrealname}-->" readonly  class="layui-input" >
              </div>
              <div class="layui-inline">
                  <button type="button" class="layui-btn" id='checkpro'><!--{$lang.page.public.select}--></button>
              </div>
            </div>
            <!--{/if}-->
            </div>
            <!--{/if}-->

            <div class="layui-form-item">
              <label class="layui-form-label"><!--{$lang.page.public.header}--></label>
              <div class="layui-inline">
               <div class="layui-upload">
                  <blockquote class="viewpicList"><!--{$lang.page.public.smallimg}-->：
                  <ul>
                    <li class="viewpic" id="picdemo1" <!--{if empty($datainfo.header_url)}-->style="display:none;"<!--{/if}-->>
                      <img src="<!--{$datainfo.header_url}-->" style="cursor: pointer;"  id="imgbig" data-set="<!--{$datainfo.header_url}-->"/>
                    </li>
                    <button type="button" class="picup" id="test1">+</button>
                  </ul>
                  </blockquote>
                </div>
                 <span>（<!--{$lang.page.public.suggest}-->1:1<!--{$lang.page.public.dimensions}-->）</span>
                 <input id="imgOne" name="imgOne" type="hidden"/>
              </div>
            </div>
           
            <div class="layui-form-item">
            <label class="layui-form-label"><!--{$lang.page.table.status}--></label>
            <div class="layui-input-block">
              <input type="radio" name="status" value="0" title="<!--{$lang.page.table.close}-->" <!--{if $datainfo.status eq 0}--> checked<!--{/if}-->  >&nbsp;&nbsp;<input type="radio" name="status" value="1" title="<!--{$lang.page.table.normal}-->" <!--{if $datainfo.status eq 1}--> checked<!--{/if}-->>
            </div>
          </div>
                  
          <div class="layui-form-item layui-layout-admin">
              <div class="layui-footer" style="left: 0;">
                <button class="layui-btn" type="button" id="submit" lay-submit lay-filter="submit"><!--{$lang.page.public.submit}--></button>
                <button type="reset" id='reset' class="layui-btn layui-btn-primary"><!--{$lang.page.public.reset}--></button>
                <button type="button" class="layui-btn layui-btn-primary" onClick="xadmin.close();" ><!--{$lang.page.table.back}--></button>
              </div>
          </div>

        </form>
      </div>
    </div>
<script src="/static/lay/layui/layui.js"></script>
<script type="text/javascript">
    layui.config({
     base: '/static/lay/' //静态资源所在路径
   }).extend({
     xadmin: 'lib/xadmin' //弹窗
   }).use(['jquery', 'layer','xadmin', 'form', 'element', 'upload'], function(){
    var form = layui.form
       ,upload = layui.upload;
    form.render(null, 'component-form-group');

    /* 自定义验证规则 */
    // var mobile = /^0[9]\d{8}$/,phone = /^0\d{2,3}-?\d{7,8}$/;
    var mobile = /^\d{6,13}$/;
    // var mobile = /^0[1357]\d{8,9}$/; //越南手机号验证
    var paypwd = /^\d+$/;
    var password = /^[A-Za-z0-9]+$/
    form.verify({

      username: function(value){
        if(value.length < 1){
          return '账户不能为空';
        }
      }
      ,mobile: function(value){
          var flag = mobile.test(value);
          if(!flag){
              return '请输入正确座机号码或手机号';
          }
      }
      ,password: function(value){
        if(value.length>1){
          var flag = password.test(value);
          if(value.length <6 || value.length >16){
             return '请输入正确的密码，密码为6-16位数字字母组合';
          }
          if(!flag){
              return '请输入正确的密码，密码为6-16位数字字母组合';
          }
        }     
      }
      ,paypwd: function(value){
        if(value.length>1){
          var flag = paypwd.test(value);
          if(value.length != 6 ){
             return '请输入正确的支付密码，支付密码为6位数字';
          }
          if(!flag){
              return '请输入正确的支付密码，支付密码为6位数字';
          }
        }  
      }
    });

    form.on('select(brickType)', function(data){ 
        var ranges = $(data.elem).find("option:selected").attr("range");
        var grade = $(data.elem).find("option:selected").attr("grade");
        $("input[name='ranges']").val(ranges);
        $("input[name='grade']").val(grade);
    });

    form.on('submit(submit)', function (data) {
        $('#submit').attr("disabled",true);
        $('#submit').addClass('layui-btn-disabled');
        $.post('#',data.field,function(res){
            if(res.code == 200){
                layer.msg(res.msg);
                setTimeout(() => {
                    window.parent.location.reload();
                    xadmin.close();
                }, 1000); 
              }else{
                layer.msg(res.msg);
              }
        })
        return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });

    //重置按钮，可以提交失败的时候再次提交
    $('#reset').click(function(){
        $('#submit').removeAttr("disabled");
        $('#submit').removeClass('layui-btn-disabled');
    });

    var uploadInst = upload.render({
      elem: '#test1'
      ,url: '/user/common/uploadimg/?folder=user'
      ,done: function(res){
      //上传成功
      if (res.code == 200) {
            $('#imgbig').attr('src', res.data.src); //图片链接（base64）
            $('#imgbig').attr('data-set', res.data.src); //图片链接（base64）
            $('#imgOne').attr('value', res.data.src); //图片链接（base64)
            $('#picdemo1').show();
          } else {
            layer.msg(res.msg);
          }
      }
    });

    $('#checkpro').on('click', function(){
        var data = 'checkpro';
        layer.open({
          type: 2,
          title: '<!--{$lang.page.public.select}-->',
          offset: '50px', 
          closeBtn: 1, //要显示关闭按钮
          anim: 2,
          shadeClose: true, //开启遮罩
          // moveOut: true,
          area: ['1024px', '700px'],
          content: '/user/account/checklist/'
          ,resize:false
          ,maxmin: false //开启最大化最小化按钮
          ,success:function (layero, index) {
            var iframe = window['layui-layer-iframe'+index]; // 获取子页面的iframe
            iframe.child(data);// 向子页面的全局函数child传参
          }
        });
        window.ppp = function(value){
            if (value != "") {
                value = value.split("-")
                $('input[name="pid"]').val(value[0]); //将子页面传来的值赋值到指定输入框
                $('#subrealname').val(value[1]); //将子页面传来的值赋值到指定输入框
            }
        }
    })

    $('#imgbig').on('click', function(e){
        var data = e.target.dataset.set;
        parent.layer.open({
            type: 1, // 显示图片时，type选1
            shadeClose: true,
            area:['auto','auto'], // 区域，auto指宽度自适应，高度设置为700px
            title: '<!--{$lang.page.public.showimg}-->', // false表示不显示标题
            maxmin : false, //添加最大化
            content: "<img src='" + data + "' style='max-width:1280px; max-height:620px;'/>" // img标签
        });
    })

  });

</script>
</body>
</html>

